<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background-color: cornflowerblue;
        }
    </style>
</head>
<body>
    <!--  
        // 封装函数可以批量设置样式
        function setStyle(){ } -->
        <div>最爱的人是谁</div>
        <script>
           function setStyle(elem,attr,value){
            return elem.style[attr]=value
            }
            var res=document.querySelector('div');
            setStyle(res,'background','green');
            setStyle(res,'color','red');
            setStyle(res,'font-size','30px');
        </script>
</body>
</html>